package pap.utils;

import pap.Point;
import pap.Vector;

public class UtilMethods {

	public static double getRandomDouble(double min, double max) {
		return Math.random() * (max - min) + min;
	}

	public static int getRandomInt(int min, int max) {
		return (int) (Math.random() * (max - min) + min);
	}

	public static Point getRandom2DPoint(double minX, double maxX, double minY,
			double maxY) {
		double randomX = getRandomDouble(minX, maxX);
		double randomY = getRandomDouble(minY, maxY);

		return new Point(new double[] { randomX, randomY });
	}

	public static Vector getRandom2DVector(double minIntensity,
			double maxIntensity) {
		// Generate a random intensity
		double intensity = getRandomDouble(minIntensity, maxIntensity);

		// Generate a random angle
		double angleRadians = Math.toRadians(getRandomInt(0, 360));

		// Return the vector represented by the generated angle and intensity
		return new Vector(new Point(new double[] { Math.sin(angleRadians),
				Math.cos(angleRadians) })).multiply(intensity);
	}

}
